package com.nmsl.nurse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.nurse.domain.MHospitalizationRegistration;
import com.nmsl.nurse.service.IMHospitalizationRegistrationService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 住院登记Controller
 * 
 * @author mengdi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/nurse/beinhospital")
public class MHospitalizationRegistrationController extends BaseController
{
    @Autowired
    private IMHospitalizationRegistrationService hospitalizationRegistrationService;

    /**
     * 查询住院登记列表
     */
    @PreAuthorize("@ss.hasPermi('nurse:beinhospital:list')")
    @GetMapping("/list")
    public TableDataInfo list(MHospitalizationRegistration MHospitalizationRegistration)
    {
        startPage();
        List<MHospitalizationRegistration> list = hospitalizationRegistrationService.selectHospitalizationRegistrationList(MHospitalizationRegistration);
        return getDataTable(list);
    }

    /**
     * 导出住院登记列表
     */
    @PreAuthorize("@ss.hasPermi('nurse:beinhospital:export')")
    @Log(title = "住院登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MHospitalizationRegistration MHospitalizationRegistration)
    {
        List<MHospitalizationRegistration> list = hospitalizationRegistrationService.selectHospitalizationRegistrationList(MHospitalizationRegistration);
        ExcelUtil<MHospitalizationRegistration> util = new ExcelUtil<MHospitalizationRegistration>(MHospitalizationRegistration.class);
        util.exportExcel(response, list, "住院登记数据");
    }

    /**
     * 获取住院登记详细信息
     */
    @PreAuthorize("@ss.hasPermi('nurse:beinhospital:query')")
    @GetMapping(value = "/{registrationId}")
    public AjaxResult getInfo(@PathVariable("registrationId") Long registrationId)
    {
        return success(hospitalizationRegistrationService.selectHospitalizationRegistrationByRegistrationId(registrationId));
    }

    /**
     * 新增住院登记
     */
    @PreAuthorize("@ss.hasPermi('nurse:beinhospital:add')")
    @Log(title = "住院登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MHospitalizationRegistration MHospitalizationRegistration)
    {
        return toAjax(hospitalizationRegistrationService.insertHospitalizationRegistration(MHospitalizationRegistration));
    }

    /**
     * 修改住院登记
     */
    @PreAuthorize("@ss.hasPermi('nurse:beinhospital:edit')")
    @Log(title = "住院登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MHospitalizationRegistration MHospitalizationRegistration)
    {
        return toAjax(hospitalizationRegistrationService.updateHospitalizationRegistration(MHospitalizationRegistration));
    }

    /**
     * 删除住院登记
     */
    @PreAuthorize("@ss.hasPermi('nurse:beinhospital:remove')")
    @Log(title = "住院登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registrationIds}")
    public AjaxResult remove(@PathVariable Long[] registrationIds)
    {
        return toAjax(hospitalizationRegistrationService.deleteHospitalizationRegistrationByRegistrationIds(registrationIds));
    }


    @GetMapping("/list2")
    public List<MHospitalizationRegistration> list2(MHospitalizationRegistration MHospitalizationRegistration)
    {
        return hospitalizationRegistrationService.selectHospitalizationRegistrationList(MHospitalizationRegistration);
    }

}
